package main

import (
	"fmt"
	"sync"
)

func main() {
	cond := sync.NewCond(new(sync.Mutex))
	for i := 0; i < 3; i++ {
		go func(i int) {
			fmt.Println("协程启动：", i)
			cond.L.Lock() //加锁
			fmt.Println("协程加锁：", i)
			cond.Wait()
			cond.L.Unlock() //解锁
			fmt.Println("协程解锁：", i)
		}(i)
	}

	//发送信号
	cond.Signal()
}
